package com.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.common.utils.base.UuidUtil;
import com.entity.FuJianGuanXi;
import com.entity.YongHu;
import com.repository.FjgxDao;
import com.repository.UserDao;
import com.service.base.BaseServiceImp;

@Service("UserService")
public class UserServiceImp extends BaseServiceImp<YongHu> implements UserService{
	@Autowired
	private FjgxDao fjgxdao; 
	@Autowired
	private UserDao  userDao;

	@Override
	public int countPWD(YongHu yh) {
		// TODO Auto-generated method stub
		return userDao.countPWD(yh);
	}

	@Transactional
	@Override
	public void insertFj(YongHu o, String fujianId) {
		String yhId=UuidUtil.get32UUID();
		o.setId(yhId);
		super.insert(o);
		if(!fujianId.equals("")){
			if(fujianId.indexOf(",")>-1){
				String fujianIdArr[] = fujianId.split(",");
				for (int i = 0; i < fujianIdArr.length; i++) {
					FuJianGuanXi fjgx = new FuJianGuanXi();
					fjgx.setId(UuidUtil.get32UUID());
					fjgx.setScr(yhId);
					fjgx.setFjbh(fujianIdArr[i]);
					fjgxdao.insert(fjgx);
				}
			}else{
				FuJianGuanXi fjgx = new FuJianGuanXi();
				fjgx.setId(UuidUtil.get32UUID());
				fjgx.setScr(yhId);
				fjgx.setFjbh(fujianId);
				fjgxdao.insert(fjgx);
			}
		}
		
	}

	
}
